/***************************************************************************
 *   Copyright (C) 2010 by programmeboy                                    *
 *   programmeboy@gmail.com                                                *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.                                        *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             * 
 ***************************************************************************/

#ifndef __BP_H__
#define __BP_H__

#include <ntddk.h>
#include "cpu.h"

#define FLAGS_TF_MASK (1 << 8)
#define MAX_BREAK_POINT		5
#define INT3_CODE			0xCC
typedef struct _BREAKPOINT_INFO
{
	UCHAR SavedByte;
	BOOLEAN IsSet;
	ULONG TargetCR3;
	ULONG VirtualAddress;

}BREAKPOINT_INFO, *PBREAKPOINT_INFO;

typedef struct _SINGLE_STEP_INFO
{
    ULONG LastEip;  //Saved the eip of last single step
    ULONG RFlag;    //Saved the eflag of last single step
    ULONG LastInsLen;

}SINGLE_STEP_INFO, *PSINGLE_STEP_INFO;

BOOLEAN
BpSetBreakPoint(
	ULONG Address
);

VOID
BpDelBreakPoint(
	ULONG Address
);

BOOLEAN
BPIsSettingBreakPoint(
	ULONG Address
);

BOOLEAN
BPSetProcessCode(
	ULONG Address
);

BOOLEAN
BPRestoreProcessCode(
	ULONG Address
);
VOID
BPInit();

BOOLEAN 
BPIsSingleDebuging();

VOID 
BPSetSingleDebuging();

VOID 
BPDisSingleDebuging();

NTSTATUS
BPSetSingleStepDebug(
     PCPU_VM_CONTEXT pPCU
     );

BOOLEAN
BPIsOurSingleStep(
      PCPU_VM_CONTEXT pCPU
      );

#endif